package com.example.wacoffee_user.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.wacoffee_user.pojo.entity.Good;
import com.example.wacoffee_user.pojo.vo.searchVo;
import com.example.wacoffee_user.service.ICartService;
import com.example.wacoffee_user.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cart")
public class cartController {

    @Autowired
    private ICartService cartService;
    @GetMapping
    public Result getAllGoods()
    {
        return Result.success(cartService.getAllGoods());
    }

    @GetMapping("/condition")
    public Result getAllGoodsByCondition(@RequestParam String name)
    {
        if(name==null){
            return Result.success(cartService.getAllGoods());
        }
        QueryWrapper<Good> queryWrapper=new QueryWrapper<Good>().like("name",name);

        return Result.success(cartService.list(queryWrapper));
    }


}
